#include<iostream>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_set>
#include<bits/stdc++.h>
#define fi first
#define se second
#define SIZE(x) ((int)x.size())
#define out(x) cerr<<#x<<" = "<<(x)<<endl;
#define MP(a,b) make_pair(a,b)
using namespace std;
typedef long long ll;
#define VI vector<int>
#define VVI vector< vector<int> >
#define VC vector<char>
#define PI pair<int,int>
#define PL pair<ll,ll>
#define EPS 0.000001




char str[22000007];
int p[22000007];
int main(){
    #ifdef BUG
    freopen("a.in","r",stdin);
    #endif
	memset(str,0,sizeof str);
	memset(p,0,sizeof p);
	int n=0;
	str[n++]='$';
	str[n++]='#';
	char c;
	for(;;){
		c=getchar();
		if(c>'z'||c<'a')break;
		str[n++]=c;
		str[n++]='#';
	}
	if(n==2){
		cout<<0<<endl;
		return 0;
	}
	//cout<<str<<endl;
	p[0]=0;
	int mx=0,id=0;
	int res=1;
	for(int i=1;i<n;i++){
		if(i<mx)p[i]=min(p[2*id-i],mx-i);
		else p[i]=1;
		while(str[i+p[i]]==str[i-p[i]])++p[i];
		id=i+p[i]>mx?i:id;
		mx=max(mx,i+p[i]);
		res=max(res,p[i]-1);
	}
	cout<<res<<endl;
}